package com.xinjian.jianba.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xinjian.jianba.dto.UserReportDto;
import com.xinjian.jianba.exception.ResponseCode;
import com.xinjian.jianba.service.UserReportService;
import com.xinjian.jianba.utils.JsonUtil;
import com.xinjian.jianba.utils.LogBuilder;
import com.xinjian.jianba.utils.ModuleEnum;

@RestController
@RequestMapping(value = "/api/v3/jianba/report")
public class UserReportControllor extends AbstractController{
	private static final Logger LOGGER = LoggerFactory.getLogger(UserReportControllor.class);
	@Autowired
	private UserReportService userReportService;
	@PostMapping("/publish")
	public String report(@RequestBody UserReportDto userReportDto){
		LOGGER.info("举报模块{}", JsonUtil.getJsonString(userReportDto));
		int result=userReportService.userReport(userReportDto);
		if(result>0){
			return this.responseClientJsonData(ResponseCode.SUCCESS, ResponseCode.SUCCESS_MSG);
		}else{
			return this.responseClientJsonData(ResponseCode.ERROR, "举报失败,请稍后再试...");
		}
	}
}
